package com.sc.servlet.user.comment;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.sc.pojo.Comment;
import com.sc.pojo.User;
import com.sc.services.FieldServices;
import com.sc.services.UserServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;

/**
 * @description: 删除某条评论
 * @author: sc
 * @create: 2023-01-05 02:31
 **/
@WebServlet("/deleteComment")
public class deleteCommentServlet extends HttpServlet {

    private UserServices userServices = new UserServices();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        BufferedReader reader = request.getReader();
        String readLine = reader.readLine();
        Comment comment = JSONObject.parseObject(readLine, Comment.class);

        userServices.deleteComment(comment);

        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write("del_suc");



    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}